using System;
using System.Collections.Generic;
using System.Text;
using FireStarterModeller.BO;
using Habanero.BO;
using Habanero.UI.Base;
using Habanero.UI.Win;

namespace FireStarterModeller.UI
{
    public class PropertyInfosGridPanelControl : UserControlWin, IFormControl
    {
        private BusinessObjectInfo _businessObjectInfo;
        private GridAndBOEditorControl<BusinessObjectPropertyInfo> _gridAndBOEditorControl;

        public GridAndBOEditorControl<BusinessObjectPropertyInfo> GridAndBOEditorControl
        {
            get { return _gridAndBOEditorControl; }
        }

        public PropertyInfosGridPanelControl(IControlFactory controlFactory)
        {
            _gridAndBOEditorControl = new GridAndBOEditorControl<BusinessObjectPropertyInfo>(controlFactory, "default");
            IControlHabanero control = _gridAndBOEditorControl;

            BorderLayoutManager layoutManager = controlFactory.CreateBorderLayoutManager(this);
            layoutManager.AddControl(control, BorderLayoutManager.Position.Centre);

            this.Enabled = false;
        }

        public BusinessObjectInfo BusinessObjectInfo
        {
            get { return _businessObjectInfo; }
            set { 
                    _businessObjectInfo = value;
                    if (_businessObjectInfo == null)
                    {
                       
                        _gridAndBOEditorControl.SetBusinessObjectCollection(new BusinessObjectCollection<BusinessObjectPropertyInfo>());
                        this.Enabled = false;
                        return;
                    }
                        this.Enabled = true;
                        BusinessObjectCollection<BusinessObjectPropertyInfo> col = _businessObjectInfo.BusinessObjectPropertyInfos;
                        _gridAndBOEditorControl.SetBusinessObjectCollection(col);
                 }
        }


        public void SetForm(IFormHabanero form)
        {

        }
    }
}
